package com.module.oa.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.module.oa.domain.Performancerecord;
import com.module.oa.service.IPerformancerecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 绩效考核记录Controller
 * 
 * @author hezhengxian
 * @date 2023-09-12
 */
@RestController
@RequestMapping("/percord")
public class PerformancerecordController extends BaseController
{
    @Autowired
    private IPerformancerecordService performancerecordService;

    /**
     * 查询绩效考核记录列表
     */
    @RequiresPermissions("performancerecord:percord:list")
    @GetMapping("/list")
    public TableDataInfo list(Performancerecord performancerecord)
    {
        startPage();
        List<Performancerecord> list = performancerecordService.selectPerformancerecordList(performancerecord);
        return getDataTable(list);
    }

    /**
     * 导出绩效考核记录列表
     */
    @RequiresPermissions("performancerecord:percord:export")
    @Log(title = "绩效考核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Performancerecord performancerecord)
    {
        List<Performancerecord> list = performancerecordService.selectPerformancerecordList(performancerecord);
        ExcelUtil<Performancerecord> util = new ExcelUtil<Performancerecord>(Performancerecord.class);
        util.exportExcel(response, list, "绩效考核记录数据");
    }

    /**
     * 获取绩效考核记录详细信息
     */
    @RequiresPermissions("performancerecord:percord:query")
    @GetMapping(value = "/{eecordId}")
    public AjaxResult getInfo(@PathVariable("eecordId") Long eecordId)
    {
        return success(performancerecordService.selectPerformancerecordByEecordId(eecordId));
    }

    /**
     * 新增绩效考核记录
     */
    @RequiresPermissions("performancerecord:percord:add")
    @Log(title = "绩效考核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Performancerecord performancerecord)
    {
        return toAjax(performancerecordService.insertPerformancerecord(performancerecord));
    }

    /**
     * 修改绩效考核记录
     */
    @RequiresPermissions("performancerecord:percord:edit")
    @Log(title = "绩效考核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Performancerecord performancerecord)
    {
        return toAjax(performancerecordService.updatePerformancerecord(performancerecord));
    }

    /**
     * 删除绩效考核记录
     */
    @RequiresPermissions("performancerecord:percord:remove")
    @Log(title = "绩效考核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eecordIds}")
    public AjaxResult remove(@PathVariable Long[] eecordIds)
    {
        return toAjax(performancerecordService.deletePerformancerecordByEecordIds(eecordIds));
    }
}
